﻿@model ShipmentDetailsModel
@using Nop.Core.Domain.Orders;
@using Nop.Web.Models.Order;
@using Nop.Services.Localization;

<div class="tracking-details-content">

    @using (Html.BeginForm("Tracking", "Customer", new { area = "" }, FormMethod.Post))
    {
        @Html.Hidden("shipmentId", Model.Id)
        <div class="tracking-overview-table">
            <table>
                <tr>
                    <td>
                        @if (Model.CanCancelPakage)
                        {
                            <input type="submit" name="cancelPackage" class="button-grey cancel-package" value="@T("Customer.Tracking.CancelShipment")" />
                        }
                    </td>
                </tr>
                <tr>
                    <td>
                        <strong>
                            @T("Order.Shipments.Order#")@Model.Order.Id
                        </strong>

                    </td>
                    <td class="right">
                        <div class="shipped-date">
                            @T("Order.Shipments.ShippedDate"):
                            @if (Model.ShippedDate.HasValue)
                            {
                                @Model.ShippedDate.Value.ToString("D")
                            }
                            else
                            {
                                @T("Order.Shipments.ShippedDate.NotYet")
                            }
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        @if (!String.IsNullOrEmpty(Model.TrackingNumber))
                        {
                            <div class="tracking-number">
                                @T("Order.Shipments.TrackingNumber"):
                                @if (!string.IsNullOrEmpty(Model.TrackingNumberUrl))
                                {
                                    <a href="@Model.TrackingNumberUrl" target="_blank" class="tracking-url">@Model.TrackingNumber</a>
                                }
                                else
                                {
                                    @Model.TrackingNumber
                                }
                            </div>
                        }
                    </td>
                    <td class="right">
                        <div class="delivery-date">
                            @T("Order.Shipments.DeliveryDate"):
                            @if (Model.DeliveryDate.HasValue)
                            {
                                @Model.DeliveryDate.Value.ToString("D")
                            }
                            else
                            {
                                @T("Order.Shipments.DeliveryDate.NotYet")
                            }
                        </div>
                    </td>
                </tr>
            </table>
        </div>

        <div class="shipping-method">@T("Order.Shipments.ShippingMethod"): @Model.Order.ShippingMethod</div>

        <table class="tracking-details-addresses">
            <tr>
                <td>
                    <div class="shipping-address">
                        @if (Model.CanChangePickupAddress)
                        {
                            <div class="section-title">
                                <input type="submit" name="changePickupAddress" class="change-pickup-address" value="@T("Customer.Tracking.EditPickupAddress")" />
                            </div>
                        }
                        else
                        {
                            <strong>(@T("Order.Shipments.PickupAddress"))</strong>
                        }
                        @Html.Partial("_ShipmentAddress", Model.PickupAddress)
                    </div>
                </td>
                <td>
                    @if (Model.DeliveryAddress != null)
                    {
                        <div class="pickup-address">
                            @if (Model.CanChangeDeliveryAddress)
                            {
                                <input type="submit" name="changeDeliveryAddress" class="change-delivery-address" value="@T("Customer.Tracking.EditDeliveryAddress")" />
                            }
                            else
                            {
                                <strong>(@T("Order.Shipments.DeliveryAddress"))</strong>
                            }
                            @Html.Partial("_ShipmentAddress", Model.DeliveryAddress)
                        </div>
                    }
                </td>

            </tr>
        </table>
    }

    @Html.Partial("_ShipmentEvents", Model)
</div>